#!/bin/bash
# 备份脚本
cd happyTank
export LANG=en_US.UTF-8

# 修改包名
/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier com.shandong.test" happyTank/Info.plist
# 修改App名字
/usr/libexec/PlistBuddy -c "Set :CFBundleDisplayName '闪动校园'" happyTank/Info.plist

pod install
#xcodebuild -s clean
xcodebuild -workspace happyTank.xcworkspace -scheme happyTank -configuration Debug -sdk iphoneos -archivePath build/happyTank.xcarchive archive
xcodebuild -exportArchive -archivePath build/happyTank.xcarchive -exportOptionsPlist exportOptions.plist -exportPath output/happyTank.ipa
 
# 上传ipa到蒲公英
response=$(curl -F "file=@output/happyTank.ipa/happy Tank.ipa" \  -F "uKey=56f85d8d72945ad91e84fc32831e0bc9" \     -F "_api_key=75c67f7a024ec6d6a3656fb48494e0f6" \     https://www.pgyer.com/apiv1/app/upload)
baseUrl="https://www.pgyer.com/"
path=$(echo "$response" | jq -r '.data.appShortcutUrl')
echo "下载地址为： "
echo $baseUrl$path
